package com.gopay.scheduler.job;

import com.gopay.common.exception.FundException;
import com.gopay.common.util.DateUtils;
import com.gopay.remote.fundcps.service.Fund02020BizService;
import com.gopay.scheduler.GopayBaseJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 基金活期宝快赎内转做账
 * @author @author <a href="mailto:zookeeper1024@163.com">baiyunpeng</a>
 * @date 2017/12/28
 */
@Service("fundFastRedeemDoAccApplyJob")
public class FundFastRedeemDoAccApplyJob extends GopayBaseJob {
    private final static Logger LOGGER = LoggerFactory.getLogger(FundFastRedeemDoAccApplyJob.class);
    @Resource(name = "fund02020DoAcctApplyService")
    private Fund02020BizService fund02020BizService;
    @Override
    protected void doJobInternal() {
        LOGGER.info("【基金活期宝快赎做账】 =====> 【业务开始】 =>第一步账申请<=");
        String currDate = DateUtils.format(com.gopay.common.util.DateUtils.add(new Date(), Calendar.DATE, -6),"yyyyMMdd");
        String nextDate = DateUtils.format(com.gopay.common.util.DateUtils.add(new Date(), Calendar.DATE, 1),"yyyyMMdd");
        Map<String,Object> pointMap = new HashMap<>(2);
        pointMap.put("startTime",currDate);
        pointMap.put("endTime",nextDate);
        try {
            fund02020BizService.do02020FirstAcct(pointMap);
        } catch (FundException e) {
            LOGGER.error("【基金活期宝快赎做账】 <===== 业务异常 =>第一步账申请<=",e);
        }
        LOGGER.info("【基金活期宝快赎做账】 <===== 【业务结束】 =>第一步账申请<=");
    }
}
